<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('请求转发记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								appKey：<input type="text" name="appKey"/>
							</li>

							<li>
								api地址：<input type="text" name="apiUrl"/>
							</li>

							<li>
								<label>时间范围： </label>
								<input data-type="datetime" class="time-input" style="width: 93px;display: inline;" type="text" id="sTime" placeholder="开始时间" name="params[beginTime]" />
								<span>-</span>
								<input data-type="datetime" class="time-input" style="width: 93px;display: inline;" type="text" id="eTime" placeholder="结束时间" name="params[endTime]"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="api:record:remove">
					<i class="fa fa-remove"></i> 清空
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="api:record:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
    
        var editFlag = [[${@permission.hasPermi('api:record:detail')}]];
        var removeFlag = [[${@permission.hasPermi('api:record:remove')}]];
        var prefix = ctx + "api/record";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/detail/{id}",
                cleanUrl: prefix + "/clean",
				exportUrl: prefix + "/export",
                modalName: "请求转发记录",
		        showExport: true,
                columns: [
				{
					field : 'appKey', 
					title : 'appKey',
					sortable: true
				},
				{
					field : 'apiUrl', 
					title : '请求api',
				},
				{
					field : 'serverName', 
					title : '转发服务器',
				},
				{
					field : 'useTime', 
					title : '总共用时 ms',
				},
				{
					field : 'responseContentType', 
					title : '响应数据结构',
				},
				{
					field : 'forwardSuccess', 
					title : '转发状态',
					formatter: function(value, row, index) {
		                if (value) {
		                    return '<span class="badge badge-primary">正常</span>';
		                } else{
		                    return '<span class="badge badge-danger">异常</span>';
		                }
		            }
				},
				{
					field : 'createTime', 
					title : '请求时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>详情</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>